//
//  OrderViewController.m
//  CarNetwork
//
//  Created by fzuacm on 16/4/18.
//  Copyright © 2016年 fzu_z. All rights reserved.
//

#import "OrderViewController.h"
#import "OrderSuccessViewController.h"

@interface OrderViewController ()<UITextFieldDelegate>
{
    UIImageView *_imageView;

}

@end

@implementation OrderViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self addGesture];
    // Do any additional setup after loading the view.
    [self creatImageView];
    [self creatView];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)addGesture
{
    UITapGestureRecognizer *tap1=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewtaped:)];
    tap1.cancelsTouchesInView=NO;
    [self.view addGestureRecognizer:tap1];
}

#pragma view
-(void)creatView
{
    UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 50, 70, 40)];
    nameLabel.text=@"姓名:";
    nameLabel.textAlignment = NSTextAlignmentRight;
    [_imageView addSubview:nameLabel];
    UILabel *timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 100, 70, 40)];
    timeLabel.textAlignment = NSTextAlignmentRight;
    timeLabel.text = @"时间:";
    [_imageView addSubview:timeLabel];
    UILabel *stationLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 150, 70, 40)];
    stationLabel.text=@"加油站:";
    stationLabel.textAlignment=NSTextAlignmentRight;
    [_imageView addSubview:stationLabel];
    UILabel *typeLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 200, 70, 40)];
    typeLabel.text = @"加油类型:";
    typeLabel.textAlignment=NSTextAlignmentRight;
    [_imageView addSubview:typeLabel];
    UILabel *rangeLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 250, 70, 40)];
    rangeLabel.text = @"加油数量:";
    rangeLabel.textAlignment=NSTextAlignmentRight;
    [_imageView addSubview:rangeLabel];
    UITextField *nameText = [[UITextField alloc]initWithFrame:CGRectMake(20+70+20, 50+20, 130, 40)];
    nameText.delegate = self;
    nameText.borderStyle = UITextBorderStyleRoundedRect;
    nameText.placeholder = @"name";
    [self.view addSubview:nameText];
    
    UILabel *timeYearLabel = [[UILabel alloc] initWithFrame:CGRectMake(20+70+20+60, 100, 20, 40)];
    timeYearLabel.textAlignment = NSTextAlignmentRight;
    timeYearLabel.text = @"年";
    [_imageView addSubview:timeYearLabel];
    UILabel *timeMonthLabel = [[UILabel alloc] initWithFrame:CGRectMake(20+70+20+60+20+40, 100, 20, 40)];
    timeMonthLabel.textAlignment = NSTextAlignmentRight;
    timeMonthLabel.text = @"月";
    [_imageView addSubview:timeMonthLabel];
    UILabel *timeDayLabel = [[UILabel alloc] initWithFrame:CGRectMake(20+70+20+60+20+40+20+40, 100, 20, 40)];
    timeDayLabel.textAlignment = NSTextAlignmentRight;
    timeDayLabel.text = @"日";
    [_imageView addSubview:timeDayLabel];

    UITextField *timeYearText = [[UITextField alloc] initWithFrame:CGRectMake(20+70+20, 100+20, 60, 40)];
    timeYearText.delegate = self;
    timeYearText.borderStyle = UITextBorderStyleRoundedRect;
    timeYearText.placeholder = @"2016";
    [self.view addSubview:timeYearText];
    UITextField *timeMonthText = [[UITextField alloc] initWithFrame:CGRectMake(20+70+20+60+20, 100+20, 40, 40)];
    timeMonthText.delegate = self;
    timeMonthText.borderStyle = UITextBorderStyleRoundedRect;
    timeMonthText.placeholder = @"1";
    [self.view addSubview:timeMonthText];
    UITextField *timeDateText = [[UITextField alloc] initWithFrame:CGRectMake(20+70+20+60+20+40+20, 100+20, 40, 40)];
    timeDateText.delegate = self;
    timeDateText.borderStyle = UITextBorderStyleRoundedRect;
    timeDateText.placeholder = @"1";
    [self.view addSubview:timeDateText];
    
    UITextField *stationText = [[UITextField alloc]initWithFrame:CGRectMake(20+70+20, 150+20, 130, 40)];
    stationText.delegate =self;
    stationText.borderStyle = UITextBorderStyleRoundedRect;
    stationText.placeholder = @"station";
    [self.view addSubview:stationText];
    UITextField *typeText = [[UITextField alloc]initWithFrame:CGRectMake(20+70+20, 200+20, 130, 40)];
    typeText.delegate = self;
    typeText.borderStyle = UITextBorderStyleRoundedRect;
    typeText.placeholder = @"type";
    [self.view addSubview:typeText];
    UITextField *rangeText = [[UITextField alloc]initWithFrame:CGRectMake(20+70+20, 250+20, 100, 40)];
    rangeText.delegate = self;
    rangeText.borderStyle = UITextBorderStyleRoundedRect;
    rangeText.placeholder =@"1";
    [self.view addSubview:rangeText];
    UILabel *rangeHowLabel = [[UILabel alloc] initWithFrame:CGRectMake(20+70+20+110, 250, 20, 40)];
    rangeHowLabel.textAlignment = NSTextAlignmentRight;
    rangeHowLabel.text = @"升";
    [_imageView addSubview:rangeHowLabel];
    
    
    UIButton *orderButton = [UIButton buttonWithType:UIButtonTypeSystem];
    orderButton.frame=CGRectMake(140, 350+20, 40, 40);
    
    [orderButton setTitle:[NSString stringWithFormat:@"预约"] forState:UIControlStateNormal];
    [orderButton addTarget:self action:@selector(aboutall:) forControlEvents:UIControlEventTouchUpInside];
    
    //[orderButton setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:@"oil.png"]] forState:UIControlStateNormal];
    
    [self.view addSubview:orderButton];
    
}
-(void)creatImageView
{
    _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 20, self.view.frame.size.width, self.view.frame.size.height - 64)];
    _imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"default.png"]];
    [self.view addSubview:_imageView];
}

-(void)aboutall:(UIButton *)btn
{
    OrderSuccessViewController *OrderSuccess=[[OrderSuccessViewController alloc] init];
    OrderSuccess.title=@"预约成功";
    [self.navigationController pushViewController:OrderSuccess animated:YES];
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
-(void)viewtaped:(UIGestureRecognizer *)tap1
{
    [self.view endEditing:YES];
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}


@end
